<?
session_start();

require_once('config.php');
require_once('class/cls_product.php');

$product			= new cls_product();

if (isset($_REQUEST['recid']))

{

$object = $product->show_product($_REQUEST['recid']);

//$x =  $object['product_id'];


}

if (isset($_REQUEST['logout']))

{
	session_destroy();
	unset($_SESSION['username']);
	unset($_SESSION['id']);
	header("Location: index.php");
	exit();
}//LogOut

 

if (isset($_POST['Edit']))

{

	if (($_SESSION['username']=="admin") || ($_SESSION['id'] == $_POST['coordinator_id']))	
		{ 
		 	$product->edit_product($_POST);		 

		 	 $recid = $_POST['cid'];
		
		/* Uploading Image Files */
			$file 	= $_FILES['myfile'];
			if ($file['name'] != "")	
				{
					$path = "um-img/" . $recid . ".jpg";   // make like um-img/1.jpg
				
					if (!copy($file['tmp_name'], $path)) 
						{
							echo "failed to copy your file...\n";
						}
					else {
							echo "Your file has been successfully uploaded!";
				  		}
				}
		 }
		
}					
					

      	
?>
<html>
<head>
<title></title>
<link href="style.css" type="text/css" rel="stylesheet">

<link href="um_sty.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#F7F9F0">

<!-- Results table -->
<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>" enctype="multipart/form-data">
<input type="hidden" name="cid" value="<?= $_REQUEST['recid'] ?>">

<!-- Search -->
<tr>
	<td>
		<table id="Table_01" width="775" height="32" align="center" border="0" cellpadding="0" cellspacing="0">

	<tr>

		<td width="233" height="32"><img src="images/UMG_Banner.jpg" width="543" height="100" alt=""></td>

		<td><img src="images/UMG_Banner_pic.jpg" width="231" height="100" alt=""></td>
	</tr>
</table>  </td></tr>
  <tr>
    <td ><table id="Table_02" width="775" height="24" align="center" bgcolor="#000000" border="0" cellpadding="0" cellspacing="0">

	<tr>

		<td width="544" align="left" valign="middle">

		&nbsp;&nbsp;&nbsp;<a  href="index.php" class="ummenu" >Home</a>		

		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		
		<a href="customer_service.php" class="ummenu">Customer Services</a>
		
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

		<a href="contact_us.php" class="ummenu">Contact Us</a>
		
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

		<a href="aboutus.php" class="ummenu">About Us</a>


		

		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

		<td width="231" height="24" align="right" valign="middle"><a href="http://66.94.233.46/babelfish/trurl_pagecontent?lp=en_ja&trurl=http%3a%2f%2fwww.umgroups.com">

		</a>&nbsp;&nbsp;

		<a href="http://66.94.233.46/babelfish/trurl_pagecontent?lp=en_zt&trurl=http%3a%2f%2fwww.umgroups.com">		</a>&nbsp;&nbsp;

		<a href="http://66.94.233.46/babelfish/trurl_pagecontent?lp=en_ko&trurl=http%3a%2f%2fwww.umgroups.com">		</a>&nbsp;&nbsp;&nbsp;&nbsp;</td>

	</tr>

</table>
<table id="Table_01" width="775" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF" style="border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC" >
		 <tr>
          <td>
		  <table id="Table_01" width="700" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF">
<!-- Search -->
<tr>
  <td>&nbsp;</td>
  <td align="right">&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td align="right">&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td align="right">&nbsp;</td>
</tr>
<tr>
	<td>
		  <? if (isset($_POST['Edit']))
		  
		  		{ 
					if ($_SESSION['username']=="admin")
					{ 
						echo "<h3>Updated Successfully.</h3>"; 
					}					
					else if ($_SESSION['id'] != $_POST['coordinator_id']) 
					{
						 echo "<font color='red'><strong>It is not your username and password. So you have not a chance to update. Please 					Log out.</strong></font>"; 
				    } 
					else		  
        			{ 
						echo "<h3>Updated Successfully.</h3>"; 
					}
				}
		?></td>
          <td align="right"><a href="<?= $_SERVER['PHP_SELF'] ?>?logout">Logout</a></td>
		  <?= (isset($errname)) ? "<td><font color='red'><strong>".$errname."</strong></font></td>" : "" ?>
        </tr>
		<tr>
          <td valign="top" colspan="2">		</td>
         </tr>
		 <?
		 if (count($object) > 0)
		{
			foreach ($object as $row) {

		?>
		 <tr><td colspan="2" height="10px"></td></tr>
		 <tr>
          <td valign="top"></td>
          <td><input type="hidden" name="coordinator_id" value="<?= $row['coordinator_id']?>"></input></td>
        </tr>
      	<tr>
          <td valign="top"></td>
          <td><input type="hidden" name="product_id" value="<?= $row['product_id']?>"></input></td>
        </tr>
		<tr>
			<td>Your Current Image </td>			
			<td><img width="80" height="50" src="um-img/<?=$_REQUEST['recid'].".jpg"  ?>"></td>
		  </tr>
		<tr>
		  <td>&nbsp;</td>
		  <td>&nbsp;</td>
		  </tr>
		  <tr>
			<td>Choose your Image to Upload</td>
			<td><input name="myfile" type="file" size="50"></td>
		  </tr>
		<tr>
          <td valign="top">Brand</td>
          <td><input type="text" name="brand" value="<?= $row['brand']?>"></input></td>
        </tr>
		<tr>
          <td valign="top">Type</td>
          <td><input type="text" name="type" value="<?= $row['type']?>"></input></td>
        </tr>
		<tr>
          <td valign="top">Price</td>
          <td><input type="text" name="price" value="<?= $row['price']?>"></input></td>
        </tr>
		<?			
		}//for		
		?>
		
		<tr><td colspan="2" height="10px"></td></tr>
		<tr><td></td>
		<td><input type="submit" value="Edit" name = "Edit" ></td></tr>
		<tr>
		  <td></td>
		  <td>&nbsp;</td>
		  </tr>
		<tr>
		  <td></td>
		  <td>&nbsp;</td>
		  </tr>
		<tr>
		  <td></td>
		  <td>&nbsp;</td>
		  </tr>
		<tr>
		  <td></td>
		  <td>&nbsp;</td>
		  </tr>
		<? } ?></table>
		<table align="center" border="0" cellpadding="0" cellspacing="0" width="775" id="table6" bgcolor="#FFFFFF" style="border-bottom: 3px solid #DF8A0B;">


			<tr>

				<td height="2" colspan="2" bgcolor="#CCCCCC" class="foot"></td>
			</tr>
			<tr>
			  <td height="30" colspan="2" class="foot">&nbsp;</td>
			  </tr>

			<tr>

				<td class="foot" align="center" colspan="2">

				<a class="foot" href="index.php">Home</a> |  

				<a class="foot" href="umgcontactus.htm">Contact us</a> |

				<a class="foot" href="umgroup.htm">UM Group</a></td>
			</tr>

			<tr>

				<td class="copy" style="padding-left: 3px" colspan="2">&nbsp;</td>
			</tr>

			<tr>

				<td class="copy" style="padding-left: 3px" width="50%">Privacy | &copy; Copyright All right reserved<span style>

				</span><a class="copy" href="http://www.umgroups.com">www.umgroups.com</a></td>

				<td class="copy" style="padding-right:3px" align="right" width="50%" valign="top">

				United Machinery Group Myanmar</td>
			</tr>

			<tr>

				<td height="30" colspan="2" class="foot">&nbsp;</td>
			</tr>
		</table>
	</td>
</tr>
</table>
</form><br><br><br><br>

</body>
</html>